 
import { ABaseDecision } from "GameLoop/DecisionMaking/BaseDecision";
/**
 * 更新内存属性
 * 包括container
 * site 
 * repair目标
 */
export class UpdateEntitymemoryDecision< T extends "room"="room"> extends ABaseDecision<T>
{
   
    public isExpired(event: AddRoomEvent, region: string): boolean 
    {
        return true;
    }
    public makeTask(event: AddRoomEvent, region: string): IDecisionCode<T>|false
    {
        const room = Game.rooms[event.region];
        if(event.region == event.room)
        {
            const spawnentity = room.getEntity("SpawnEntity");
            spawnentity.updateMemory();
            const mineentity = room.getEntitys("InnerMineEntity");
            for(const e of mineentity)
            {
                e.updateMemory();
            }
            const controller = room.controller!;
            controller?.updateMemory();
            const minierial = room.getEntity("MinerialEntity");
            minierial?.updateMemory();
            const coreentity = room.getEntity("CoreEntity");
            coreentity.updateMemory();
            if(room.controller!.level<=5)
            {
                const upgrader = room.getEntitys("TeamUpgrader");
                for(const e of upgrader)
                {
                    e.updateMemory();
                }
                if(upgrader.length == 0)
                {
                    room.log(`warn`,`没有Teamupgrader`);
                }
            }
        }
        else
        {
            const outMine = room.getEntitys("OutMineEntity");
            for(const e of outMine)
            {
                if(e.roomName == event.room)
                {
                    e.updateMemory();
                }
            }
        }
        // this.WorldGetter.Station.PollStructure(event.room,true);
        return false;
        // return code
    }
    
}